<?php

use App\Http\Controllers\ActivityController;
use App\Http\Controllers\AdminAddressController;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\BlindActivityController;
use App\Http\Controllers\BlindCateController;
use App\Http\Controllers\BlindController;
use App\Http\Controllers\CaptchaController;
use App\Http\Controllers\CommissionController;
use App\Http\Controllers\DicController;
use App\Http\Controllers\DicdataController;
use App\Http\Controllers\FileController;
use App\Http\Controllers\FreightTemplateController;
use App\Http\Controllers\HotBlindController;
use App\Http\Controllers\IntegralController;
use App\Http\Controllers\IntegralRecordController;
use App\Http\Controllers\MenuController;
use App\Http\Controllers\NormController;
use App\Http\Controllers\OrderController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\ShopCateController;
use App\Http\Controllers\ShopController;
use App\Http\Controllers\PublicController;
use App\Http\Controllers\SignConfigController;
use App\Http\Controllers\SwiperController;
use App\Http\Controllers\SystemMsgController;
use App\Http\Controllers\UserAddressController;
use App\Http\Controllers\UserController;
use App\Models\FreightTemplate;
use App\Models\IntegralRecord;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

// Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
//     return $request->user();
// });

/**
 * 后台 后台接口统一加  v1
 */
// 登录 注册
Route::controller(AuthController::class)->prefix('v1/auth')->group(function () {
    // 登录
    Route::post('/login', 'login');
    // 退出登录
    Route::post('/logout', 'logout');
    // 注册
    Route::post('/logon', 'logon');
    // 路由
    Route::get('/routes', 'routes');
    // 用户信息和权限
    Route::get('/me', 'me');
    // 验证码
    Route::get('/captcha', CaptchaController::class);

    // 邮箱验证码
    Route::get('emailcode', 'emailcode');
});

Route::controller(null)->prefix('v1')->group(function () {
    // 菜单管理
    Route::get('menus/options', [MenuController::class, 'options']);
    Route::apiResource('menus', MenuController::class);
    // 角色管理
    Route::get('roles/{id}/menusId', [RoleController::class, 'menusId']);
    Route::put('roles/{id}/menus', [RoleController::class, 'menus']);
    Route::apiResource('roles', RoleController::class);
    // 字典管理
    Route::apiResource('dics', DicController::class);
    // 字典数据管理
    Route::get('/dict/options', [DicdataController::class, 'options']);
    Route::get('/dict/selectoption/{type}', [DicdataController::class, 'selectoption']);
    Route::apiResource('dict', DicdataController::class);
    // 用户管理
    Route::get('/admin/myextend', [AdminController::class, 'myextend']);
    Route::put('/admin/updateinfo', [AdminController::class, 'updateinfo']);
    Route::apiResource('admin', AdminController::class);

    // 商品分类管理
    Route::apiResource('shopcate', ShopCateController::class);
    // 商品管理
    Route::apiResource('shop', ShopController::class);
    // 盲盒分类管理
    Route::apiResource('blindcate', BlindCateController::class);
    // 盲盒管理
    Route::put('blind/listed/{id}', [BlindController::class, 'listed']);
    Route::put('blind/delisted/{id}', [BlindController::class, 'delisted']);
    Route::put('blind/examine/{id}', [BlindController::class, 'examine']);
    Route::put('blind/reject/{id}', [BlindController::class, 'reject']);
    Route::apiResource('blind', BlindController::class);

    // 附件管理
    Route::apiResource('file', FileController::class);

    // 规格管理
    Route::apiResource('norm', NormController::class);
    // 订单管理
    Route::apiResource('order', OrderController::class);
    // 佣金配置
    Route::get('commission/default', [CommissionController::class, 'defaultOption']);
    Route::post('commission/updatedefault', [CommissionController::class, 'updateDefaultOption']);
    Route::apiResource('commission', CommissionController::class);

    // 前台管理
    Route::get('user', [UserController::class, 'index']);
    Route::put('user/{id}', [UserController::class, 'updateStatus']);
    // 轮播图
    Route::apiResource('swiper', SwiperController::class);
    // 热门盲盒
    Route::apiResource('hotblind', HotBlindController::class);
    // 活动列表
    Route::apiResource('activity', ActivityController::class);
    // 盲盒活动
    Route::apiResource('blindactivity', BlindActivityController::class);

    // 签到配置
    Route::apiResource('signconfig', SignConfigController::class);

    // 积分配置
    Route::apiResource('integral', IntegralController::class);
    // 积分记录
    Route::apiResource('interecord', IntegralRecordController::class);
    // 系统通知
    Route::apiResource('systemmsg', SystemMsgController::class);
    // 运费模板
    Route::apiResource('freight', FreightTemplateController::class);
    // 收货地址
    Route::apiResource('address', AdminAddressController::class);
});



/**
 * 前台接口 前台接口统一加  v2
 */
// 登录 注册
Route::controller(AuthController::class)->prefix('v2/auth')->group(function () {
    // 微信小程序登录
    Route::post('/wechatlogin', 'wechatLogin');
});

// 前台接口
Route::controller(null)->prefix('v2')->group(function () {
    // 轮播图查询
    Route::get('swiper', [PublicController::class, 'swiper']);
    // 热门活动查询
    Route::get('activity', [PublicController::class, 'activity']);
    // 盲盒查询
    Route::get('blind', [PublicController::class, 'blind']);
    // 盲盒分类查询
    Route::get('blindcate', [PublicController::class, 'blindcate']);
    // 活动盲盒查询
    Route::get('blindactivity/{id}', [PublicController::class, 'blindactivity']);


    // 修改用户信息
    Route::put('user/{id}', [UserController::class, 'update']);
    Route::put('password/{id}', [UserController::class, 'password']);
    // 用户收获地址
    Route::apiResource('address', UserAddressController::class);
});
